package com.hebust.controller;

import com.hebust.service.StudentsService;
import com.hebust.utils.ResultVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController  // 控制层 异步的  所有控制层类都要加
@Api(value = "提供了学生的相关接口", tags = "学生模块")  // 类注解  对该控制器类进行功能说明
@CrossOrigin  // 解决跨域问题
public class StudentController {
    @Autowired
    private StudentsService studentsService;

    @GetMapping("/show_selectcourse")
    @ApiOperation("可选课程展示接口")
    public ResultVo show_selectcourse(String name, @RequestParam(defaultValue = "1") int pageNum) {
        return studentsService.show_selectcourse(name, pageNum);
    }

    @PostMapping("/add_selectcourse")
    @ApiOperation("选修请求接口")
    public ResultVo add_selectcourse(int sid, int cid, String name, int tid) {
        return studentsService.add_selectcourse(sid, cid, name, tid);
    }

    @PutMapping("/update_select")
    @ApiOperation("选修成功后修改页面")
    public ResultVo update_select(int id) {
        return studentsService.update_select(id);
    }

    @GetMapping("/select_course")
    @ApiOperation("查询是否重复选修一个课程")
    public ResultVo select_course(int id, int sid) {
        return studentsService.select_course(id, sid);
    }

    @PostMapping("insert_teacherscore")
    @ApiOperation("添加老师分数表")
    public ResultVo insert_teacherscore(int sid, int tid, int cid) {
        return studentsService.insert_teacherscore(sid, tid, cid);
    }

    @GetMapping("/select_grade")
    @ApiOperation("获取当前用户的年级信息")
    public ResultVo select_grade(int sid) {
        return studentsService.select_grade(sid);
    }


    // 学生课程
    @GetMapping("/show_studentcourse")
    @ApiOperation("已选课程展示接口")
    public ResultVo show_studentcourse(int sid, @RequestParam(defaultValue = "1") int pageNum) {
        return studentsService.show_studentcourse(sid, pageNum);
    }

    @GetMapping("/search_id")
    @ApiOperation("查询选课的id")
    public ResultVo search_id(int sid, String name) {
        return studentsService.search_id(sid, name);
    }

    @DeleteMapping("/delete_studentcourse")
    @ApiOperation("退选课程")
    public ResultVo delete_studentcourse(int id) {
        return studentsService.delete_studentcourse(id);
    }

    @PutMapping("/update_studentcourse")
    @ApiOperation("修改已选择人数")
    public ResultVo update_studentcourse(int cid) {
        return studentsService.update_studentcourse(cid);
    }

    @DeleteMapping("/delete_teacherscore")
    @ApiOperation("删除老师信息表")
    public ResultVo delete_teacherscore(int sid, int cid) {
        return studentsService.delete_teacherscore(sid, cid);
    }

    // 考试地点查询
    @GetMapping("/show_exam")
    @ApiOperation("考试地点查询")
    public ResultVo show_exam(int sid, @RequestParam(defaultValue = "1") int pageNum) {
        return studentsService.show_exam(sid, pageNum);
    }

    // 教师评测
    @GetMapping("/show_teacherscore")
    @ApiOperation("教师评测展示接口")
    public ResultVo show_teacherscore(int sid, @RequestParam(defaultValue = "1") int pageNum) {
        return studentsService.show_teacherscore(sid, pageNum);
    }

    @PutMapping("/update_teacherscore")
    @ApiOperation("给老师打分")
    public ResultVo update_teacherscore(int id, int score) {
        return studentsService.update_teacherscore(id, score);
    }

    @PutMapping("/update_score")
    @ApiOperation("更新teacherscore表")
    public ResultVo update_score(int sid, int cid, int score) {
        return studentsService.update_score(sid, cid, score);
    }

    // 成绩查询

    @GetMapping("/show_score")
    @ApiOperation("成绩查询接口")
    public ResultVo show_score(int sid, @RequestParam(defaultValue = "1") int pageNum) {
        return studentsService.show_score(sid, pageNum);
    }

    // 修改密码

    @PutMapping("/update_studentpassword")
    @ApiOperation("修改学生密码")
    public ResultVo update_studentpassword(int sid, String password) {
        return studentsService.update_studentpassword(sid, password);
    }

    // 课表展示
    @GetMapping("/show_courseschedule")
    @ApiOperation("学生课表展示接口")
    public ResultVo show_courseschedule(int sid) {
        return studentsService.show_courseschedule(sid);
    }

}
